package com.lp.guoguo.job;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 示例定时任务
 */
@Component
public class DemoJob implements Job {

    private static final Logger log = LoggerFactory.getLogger(DemoJob.class);

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        // 获取当前时间
        String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        // 记录日志
        log.info("DemoJob 定时任务执行时间: {}", now);

        // 在这里编写您的业务逻辑
        // 例如：数据统计、报表生成、缓存清理等

        // 记录日志
        log.info("DemoJob 定时任务执行完成");
        log.info("context 定时任务执行完成,{}",context.getJobDetail().getKey().toString());
    }
}
